package com.sell.utils;

import com.sell.enums.CodeEnum;

/**
 * @author: megan
 * @eMail: meganmail@vip.qq.com
 * @date: 2018/12/14 15:20
 * @version: v1.0
 * @description: 枚举工具类
 */
public class EnumUtil {

    public static <T extends CodeEnum> T getByCode(Integer code, Class<T> enumClass) {
        for (T each : enumClass.getEnumConstants()) {
            if (code.equals(each.getCode())) {
                return each;
            }
        }
        return null;
    }
}
